package com.zwps.biz.controller.http;

import com.zwps.biz.domain.service.ElementsService;
import com.zwps.common.controller.response.message.ResponseDataMessage;
import com.zwps.common.core.exception.ServeException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;
import java.util.List;

/**
 * 实物调查 要素查询
 */
@Controller
@RequestMapping("brief/elements")
@RestController
public class ElementsController {

    @Autowired
    ElementsService elementsService;

    /**
     * @param type (1:下游关键要素   2:库区关键要素  3:文物图斑  4:下游断面  )
     * @return
     */
    @GetMapping("/selectByType/{type}")
    public ResponseDataMessage selectElementsDataByType(@PathVariable("type") Integer type) {
        switch (type) {
            case 1:
                return ResponseDataMessage.data(elementsService.getElementsDownstream());
            case 2:
                return ResponseDataMessage.data(elementsService.getElementsReservoirArea());
            case 3:
                return ResponseDataMessage.data(elementsService.getRelicPatternSpot());
            case 4:
                return ResponseDataMessage.data(elementsService.getSectionDownstream());
        }
        throw new ServeException("类型不存在");
    }

    /**
     * 水位查询库区淹没
     * @return
     */
    @GetMapping("/reservoirInundationByWaterlevel")
    public ResponseDataMessage selectReservoirInundationByWaterlevel(BigDecimal waterlevel) {
        return ResponseDataMessage.data(elementsService.selectReservoirInundationByWaterlevel(waterlevel));
    }

    /**
     * 水位查询
     * @return
     */
    @GetMapping("/getWaterlevel")
    public ResponseDataMessage getWaterlevel() {
        return ResponseDataMessage.data(elementsService.getWaterlevel());
    }

    @GetMapping("/reservoirInundationByWaterlevels")
    public ResponseDataMessage selectReservoirInundationByWaterlevels(@RequestParam("waterlevels") BigDecimal[] numbers) {
        return ResponseDataMessage.data(elementsService.selectReservoirInundationByWaterlevels(numbers));
    }


    /**
     * 查询下游淹没
     * @return
     */
    @GetMapping("/selectReservoirSubmergenceByYear")
    public ResponseDataMessage selectReservoirSubmergence(@RequestParam(value = "year") Integer year,@RequestParam(value = "level",required = false) BigDecimal level,@RequestParam(value = "status") Integer status) {
        return ResponseDataMessage.data(elementsService.selectReservoirSubmergenceByYear(year,level,status));
    }


    /**
     * 查询库区淹没
     * @return
     */
    @GetMapping("/selectInundationByWaterlevel")
    public ResponseDataMessage selectInundationByWaterlevel(@RequestParam(value = "waterlevel")BigDecimal waterlevel) {
        return ResponseDataMessage.data(elementsService.selectInundationByWaterlevel(waterlevel));
    }




    @GetMapping("/selectReservoirSubmergenceDate")
    public ResponseDataMessage selectReservoirSubmergenceDate(@RequestParam(value = "year") Integer year,@RequestParam(value = "level",required = false) BigDecimal level,@RequestParam(value = "status") Integer status) {
        return ResponseDataMessage.data(elementsService.selectReservoirSubmergenceDate(year,level,status));
    }

    @GetMapping("/selectDeviceInfo")
    public ResponseDataMessage selectDeviceInfo() {
        return ResponseDataMessage.data(elementsService.selectDeviceInfo());
    }

    /**
     * 查询下游要素信息
     * @return
     */
    @GetMapping("/selectElementsDownstream")
    public ResponseDataMessage selectElementsDownstream() {
        return ResponseDataMessage.data(elementsService.selectElementsDownstream());
    }
    /**
     * 查询下游文物信息
     * @return
     */
    @GetMapping("/selectRelicPatternSpot")
    public ResponseDataMessage selectRelicPatternSpot() {
        return ResponseDataMessage.data(elementsService.selectRelicPatternSpot());
    }
    /**
     * 查询下游文物信息
     * @return
     */
    @GetMapping("/selectVillageDate")
    public ResponseDataMessage selectVillageDate() {
        return ResponseDataMessage.data(elementsService.selectVillageDate());
    }
    /**
     * 查询下游文物信息
     * @return
     */
    @GetMapping("/selectZSmallRsvrPositionDate")
    public ResponseDataMessage selectZSmallRsvrPositionDate() {
        return ResponseDataMessage.data(elementsService.selectZSmallRsvrPositionDate());
    }
    /**
     * 查询安置点信息
     */
    @GetMapping("/selectEmergencyContact")
    public ResponseDataMessage selectEmergencyContact() {
        return ResponseDataMessage.data(elementsService.selectEmergencyContact());
    }

}
